#include "SelectItemDialog.h"
#include "../../../model/proxy/ItemProxy.h"
#include "../EquipItemLoader.h"
#include "../../../net/NetController.h"
#include "../NotifyDefine.h"

SelectItemDialog::SelectItemDialog(void)
{
}

SelectItemDialog::~SelectItemDialog(void)
{
}

bool SelectItemDialog::init()
{
	return true;
}

SEL_MenuHandler SelectItemDialog::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName )
{
	return NULL;
}

SEL_CCControlHandler SelectItemDialog::onResolveCCBCCControlSelector( CCObject * pTarget, CCString * pSelectorName )
{
	CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onOkBtnClick", SelectItemDialog::onOkBtnClick);
	CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onReturnBtnClick", SelectItemDialog::onReturnBtnClick);
	return NULL;
}

bool SelectItemDialog::onAssignCCBMemberVariable( CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode )
{
	return false;
}

void SelectItemDialog::onNodeLoaded( CCNode * pNode, CCNodeLoader * pNodeLoader )
{
	mEquipSelectList = EquipSelectList::create();
	addChild(mEquipSelectList);
}

void SelectItemDialog::onEnter()
{
	ModelDialog::onEnter();
	SelectMode* sm = (SelectMode*)mData;
	mEquipSelectList->setSelectMode(*sm);
	refresh();
}

void SelectItemDialog::onExit()
{
	ModelDialog::onExit();
}

void SelectItemDialog::refresh()
{
	mEquipSelectList->refresh();
}

void SelectItemDialog::_onNotification( CCObject* object )
{
	
}

void SelectItemDialog::onOkBtnClick( CCObject * pSender, CCControlEvent pCCControlEvent )
{
	vector<int>& selectlList = ItemProxy::getSingletonPtr()->mSelectList;
	mEquipSelectList->getSelectList(selectlList);
	Post_Net_Notification(kVCSelectItem, (CCObject*)&selectlList);
	close();
}

void SelectItemDialog::onReturnBtnClick( CCObject * pSender, CCControlEvent pCCControlEvent )
{
	close();
}
